
// VS_BEGIN
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aCoord;
layout (location = 2) in vec3 aNormal;
layout (location = 3) in vec3 aTangent;
layout (location = 4) in vec3 aBitangent;

uniform mat4 u_model;
uniform mat3 u_modelT;

layout (std140) uniform EngineUBO
{
    mat4 u_view;
    mat4 u_project;
    vec3 u_camPos;
    vec3 u_camInfo;
};

out vec3 g_position;
out vec3 g_normal;
out vec3 g_tangent;

void main() {
    g_position = vec3(u_model * vec4(aPos, 1.0f));
    g_normal = normalize(u_modelT * aNormal);
    // g_normal = normalize(vec3(u_model * vec4(aNormal, 0.0f)));
    g_tangent = normalize(vec3(u_model * vec4(aTangent, 0.0f)));
    gl_Position = u_project * u_view * u_model * vec4(aPos, 1.0f);
}
// VS_END
// FS_BEGIN
#version 330 core 
layout (location = 0) out vec3 positionRT;
layout (location = 1) out vec3 normalRT;
layout (location = 2) out vec3 tangentRT;
layout (location = 3) out vec3 depthRT;
layout (location = 4) out vec3 albedoRT;

// Light Packet:
// position.x position.y position.z type(PointLight: 0; DirectLight: 1; AmbientSphereLight: 2)
// color.r    color.g    color.b    strength
// direct.x   direct.y   direct.z   unuse
// unuse      unuse      unuse      unuse
layout (std140) uniform LightUBO
{
    mat4 u_lights[64];
    int u_lightNum;
};

layout (std140) uniform EngineUBO
{
    mat4 u_view;
    mat4 u_project;
    vec3 u_camPos;
    vec3 u_camInfo;
};

in vec3 g_position;
in vec3 g_normal;
in vec3 g_tangent;

uniform samplerCube u_irradianceMap; 
uniform vec4        u_diffuse           = vec4(1.0f, 1.0f, 1.0f, 1.0f);

out vec4 FragColor;

void main() {
    positionRT = g_position;
    albedoRT = u_diffuse.rgb;
    normalRT = g_normal;
    tangentRT = g_tangent;
    depthRT = vec3(distance(g_position, u_camPos));
}
// FS_END
